<?php
/*
Aurus CMS - free OOP CMS
Copyright (C) 2010  Nestor Yanchuk

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (! defined('ROOT')) die();

Adminarea::getInstance()->addAdminBlock('users',__('Налаштування користувачів'),2);
Adminarea::getInstance()->addToAdminBlockLink('users','users',__('Налаштування користувачів'));
Adminarea::getInstance()->addToAdminBlockLink('users','users&amp;mod=groups',__('Налаштування груп користувачів'));
Adminarea::getInstance()->addToAdminBlockLink('users','users&amp;mod=addgroup',__('Додати групу користувачів'));
Adminarea::getInstance()->addToAdminBlockLink('users','users&amp;mod=adduser',__('Додати користувача'));
Adminarea::getInstance()->addToAdminBlockLink('users','users&amp;mod=showall',__('Переглянути список користувачів'));

Users::getInstance()->addUsergroupPermission( 'groupname', __( 'Назва групи' ), 'input' );
Users::getInstance()->addUsergroupPermission( 'adminVisit', __( 'Дозволити заходити в адмінпанель?' ), 'select', array(__( 'Ні' ), __( 'Так' ) ) );
Users::getInstance()->addUsergroupPermission( 'siteVisit', __( 'Дозволити заходити на сайт?' ), 'select', array(__( 'Ні' ), __( 'Так' ) ) );

$tpl = Template::getInstance();
$tpl->load('login');
if (Users::getInstance()->is_logged()) {
	$tpl->deleteBlock('login');
	if (Users::getInstance()->is_admin()) {
		$tpl->pregSet("~\[adminarea\](.+?)\[\/adminarea\]~is", '<a target="_blank" href="' . LINK_ROOT . 'adminarea/">\\1</a>');
	} else {
		$tpl->deleteBlock('adminarea');
	}
	$tpl->set('[logged]');
	$tpl->set('[/logged]');
	$tpl->set('{user}', Users::getInstance()->getLoggedUsersData('login'));
	$tpl->set('{avatar}', Users::getInstance()->getLoggedUsersData('avatar') ? LINK_ROOT . Users::getInstance()->getLoggedUsersData('avatar') : Config::get('noavatar', 'class_users'));
} else {
	$tpl->deleteBlock('logged');
	$tpl->set('[login]', Aurus::getInstance()->form_start('post', Url::formatUrl('users',array('do' => 'login'), 1)));
	$tpl->set('[/login]', '</form>');
}
$tpl->set('{login}',$tpl->out(),'main');
